package com.aivin.firplugin.httplib;

import org.apache.http.entity.mime.MultipartEntity;

import java.io.IOException;
import java.io.OutputStream;

public class CustomMultiPartEntity extends MultipartEntity {
    private  ProgressListener listener;

    public CustomMultiPartEntity(final ProgressListener listener) {
        super();
        this.listener = listener;
    }

    @Override
    public void writeTo(final OutputStream outstream) throws IOException {
        long fileSize = getContentLength()  ;
        super.writeTo( new CountingOutputStream(outstream, fileSize ,this.listener) );
    }
}